<template>
  <div class="w-full flex flex-col justify-start py-10 px-12">
    <div class="flex justify-start font-bold text-2xl">
      <div class="title">待办事项：</div>
    </div>
    <div class="w-full flex justify-around text-xl h-24 font-bold mt-5">
      <div class="flex flex-auto items-center px-8 bg-green-500 bg-opacity-75 mr-2 rounded-xl" @click="go('/member/auditList')">
        团员待审核：{{count1}}
      </div>
      <div class="flex flex-auto items-center px-8 bg-orange-600 bg-opacity-75 ml-2 rounded-xl" @click="go('/excellence/auditList')">
        团员推优待审核：{{count2}}
      </div>
    </div>
    <div class="w-full flex justify-around text-xl h-24 font-bold mt-5">
      <div class="flex flex-auto items-center px-8 bg-indigo-600 bg-opacity-75 mr-2 rounded-xl" @click="go('/election/authList')">
        选举待审核：{{count4}}
      </div>
      <div class="flex flex-auto items-center px-8 bg-red-600 bg-opacity-75 ml-2 rounded-xl" @click="go('/cost/audiList')">
        团费使用待审核：{{count3}}
      </div>
    </div>
  </div>
</template>
<script>
export default {
  methods: {
    go(path){
      if (this.userInfo.roleIds && this.userInfo.roleIds.length) {
        let tempArr = this.userInfo.roleIds.filter(item => item.role_id == 3 || item.role_id == 1);
        if(tempArr && tempArr.length){
          this.$router.push(path);
        }
      }
    },
    init(){
      this.$ajax({
        url: this.$api.member.findList,
        data: {
          status: 1,
        },
        success: (result) => {
          if (result && result.length) {
            this.count1 = result.length
          }
        },
      });
      this.$ajax({
        url: this.$api.excellence.findList,
        data: {
          status: 1,
        },
        success: (result) => {
          if (result && result.length) {
            this.count2 = result.length
          }
        },
      });
      this.$ajax({
        url: this.$api.cost.findList,
        data: {
          status: 1,
        },
        success: (result) => {
          if (result && result.length) {
            this.count3 = result.length
          }
        },
      });
      this.$ajax({
        url: this.$api.election.findList,
        data: {
          status: 1,
        },
        success: (result) => {
          if (result && result.length) {
            this.count4 = result.length
          }
        },
      });
    }
  },
  mounted(){
    this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
    if (this.userInfo.roleIds && this.userInfo.roleIds.length) {
      let tempArr = this.userInfo.roleIds.filter(item => item.role_id == 3 || item.role_id == 1);
      if(tempArr && tempArr.length){
        this.init()
      }
    }
  },
  data() {
    return {
      userInfo: {},
      count1: 0,
      count2: 0,
      count3: 0,
      count4: 0,
    };
  },
};
</script>
<style scoped>
</style>
